//
//  TDMinePWCheckC.m
//  TBRentClient
//
//  Created by tonbright on 2018/7/5.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TDMinePWCheckC.h"
#import "NSString+MD5Addition.h"
#import "NetWorkRequest.h"
#import "TDMinePWGetPhoneC.h"
@interface TDMinePWCheckC ()
@property (weak, nonatomic) IBOutlet UITextField *tf_oldPW;
@end

@implementation TDMinePWCheckC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [_tf_oldPW becomeFirstResponder];
}

- (IBAction)navBtnClick:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)nextBtnClick:(UIButton *)sender {
    [_tf_oldPW resignFirstResponder];
    if ([HelpObject isBlankString:_tf_oldPW.text]) {
        self.noticeText = @"请先输入旧密码";
        return;
    }
    NSDictionary *parDic = @{@"oldpwd":[_tf_oldPW.text MD5String]};
    __weak typeof(self) weakSelf = self;
    
    NSString *url = CheckPwdTD;
    
    [self progressHUDShowWithText:nil];
    [NetWorkRequest postNetRequestData:url parmeters:parDic response:^(NSDictionary *response) {
        if (response) {
            //调用登录接口
            [weakSelf progressHUDHideImmediately];
            TDMinePWGetPhoneC *minePWGetPhoneC = [[TDMinePWGetPhoneC alloc] init];
            [weakSelf.navigationController pushViewController:minePWGetPhoneC animated:YES];
        }else {
            [weakSelf progressHUDHideImmediately];
        }
    } netError:^(NSError *error) {
        [weakSelf progressHUDShowWithCompleteText:nil isSucceed:NO];
    }];
}

- (void)setupUI {
    self.view.backgroundColor = [UIColor whiteColor];
}

@end
